<template>
	<div class="admin_all">
		<admin_top></admin_top>
    <div class="zu" style="padding:0 20px;">
    	<el-input type="textarea" :rows="20" placeholder="一行一个，可直接粘贴excel纵列数据" v-model="duoxuanids"></el-input>
    </div>
    <div class="flex" style="margin-top: 20px; padding:0 20px;">
    	<el-button size="mini" type="danger" @click="chushen">提交至初审</el-button>
    	<el-button size="mini" type="danger" @click="shengchan">提交至自动生产</el-button>
    	<el-button size="mini" type="danger" @click="fahuo">发货</el-button>
      <el-button size="mini" type="danger" @click="qiangzhichongti">强制重提</el-button>
      <el-button size="mini" type="danger" @click="pilianghuidiao">批量回调</el-button>
	  <el-button size="mini" type="danger" @click="tbfh">重推审核成功并同步发货</el-button>
	  <el-button size="mini" type="danger" @click="sbtk">重推审核失败退款</el-button>
    </div>
	</div>
</template>

<script>
  import admin_top from './top.vue';
	import axios from "axios";
	export default {
    components:{
      admin_top
    },
		name: "admin_all",
		data() {
			return {
				duoxuanids: "",
				duoxuanids2: ""
			};
		},
		created() {

		},
		methods: {
		pilianghuidiao(){
				var that = this
			this.duoxuanids2 = this.duoxuanids.split(/\n/)
			for (let i in this.duoxuanids2) {
				this.duoxuanids2[i] = this.duoxuanids2[i].trim()
			}

			console.log('--==--')
			console.log(this.duoxuanids2[0])
			console.log(this.duoxuanids2)
			console.log(this.duoxuanids2.toString())
			axios.get('/api/plan-market/admin/order/notify',{
				params:{
					ids:this.duoxuanids2.toString()
				},
			} )
				.then(response => {
					console.log(response)
					if (response.data.msg.code == 0) {
						that.$message({
							message: '批量回调成功！',
							type: 'success'
						});
					} else {
						that.$message.error(response.data.msg.info);
					}
				})
		},
      qiangzhichongti:function(id){
        var that = this
        this.duoxuanids2 = this.duoxuanids.split(/\n/)
        for (let i in this.duoxuanids2) {
        	this.duoxuanids2[i] = this.duoxuanids2[i].trim()
        }
        axios.post('/api/plan-market/admin/upstream/order/force/submit', {ids:this.duoxuanids2})
        	.then(response => {
        		if (response.data.msg.code == 0) {
        			that.$message({
        				message: '强制重提成功！',
        				type: 'success'
        			});
        		} else {
        			that.$message.error(response.data.msg.info);
        		}
        	})
      },
			chushen: function() {
				this.duoxuanids2 = this.duoxuanids.split(/\n/)
				for (let i in this.duoxuanids2) {
					this.duoxuanids2[i] = this.duoxuanids2[i].trim()
				}
				console.log(this.duoxuanids2)

				axios.post(`/api/plan-market/admin/order/initial-approval`,{ids:this.duoxuanids2.toString()})
					.then(response => {
						if (response.data.msg.code == 0) {
							this.$message.success('提交成功');
						} else {
							this.$message.error(response.data.msg.info);
						}
					});
			},
			shengchan: function() {
				this.duoxuanids2 = this.duoxuanids.split(/\n/)
				for (let i in this.duoxuanids2) {
					this.duoxuanids2[i] = this.duoxuanids2[i].trim()
				}
				console.log(this.duoxuanids2)

				axios.post(`/api/plan-market/admin/order/auto-produce`,{ids:this.duoxuanids2.toString()})
					.then(response => {
						if (response.data.msg.code == 0) {
							this.$message.success('提交成功');
						} else {
							this.$message.error(response.data.msg.info);
						}
					});
			},
			fahuo: function() {
				this.duoxuanids2 = this.duoxuanids.split(/\n/)
				for (let i in this.duoxuanids2) {
					this.duoxuanids2[i] = this.duoxuanids2[i].trim()
				}
				console.log(this.duoxuanids2)

				axios.post(`/api/plan-market/admin/order/delivery`,{ids:this.duoxuanids2.toString()})
					.then(response => {
						if (response.data.msg.code == 0) {
							this.$message.success('提交成功');
						} else {
							this.$message.error(response.data.msg.info);
						}
					});
			},
			//重推审核成功并同步发货
			tbfh: function() {
				this.duoxuanids2 = this.duoxuanids.split(/\n/)
				for (let i in this.duoxuanids2) {
					this.duoxuanids2[i] = this.duoxuanids2[i].trim()
				}
				console.log(this.duoxuanids2)

				axios.post(`/api/plan-market/admin/jd/tmu-back`,{
					datas:this.duoxuanids2,
					flag:1,
					status:550
				})
					.then(response => {
						if (response.data.msg.code == 0) {
							this.$message.success('提交成功');
						} else {
							this.$message.error(response.data.msg.info);
						}
					});
			},
			//重退审核失败退款
			sbtk: function() {
				this.duoxuanids2 = this.duoxuanids.split(/\n/)
				for (let i in this.duoxuanids2) {
					this.duoxuanids2[i] = this.duoxuanids2[i].trim()
				}
				console.log(this.duoxuanids2)

				axios.post(`/api/plan-market/admin/jd/tmu-back`,{
					datas:this.duoxuanids2,
					flag:2,
					status:-460
				})
					.then(response => {
						if (response.data.msg.code == 0) {
							this.$message.success('提交成功');
						} else {
							this.$message.error(response.data.msg.info);
						}
					});
			},
		}
	};
</script>

<style lang="scss" scoped>
	.admin_all {
		background: #EAEAEA;
		min-height: 100vh;
		padding: 0px;

		.logo {
			height: 30px;
		}

		.el-input {
			width: 180px;
			margin-right: 10px;
		}

		.flex {
			display: flex;
		}



		.zu {
			margin-top: 20px;

			.tit {
				background: #ccc;
				line-height: 45px;
				padding-left: 20px;
			}

			.con {
				background: #FFFFFF;
				padding: 20px;
				line-height: 30px;
				font-size: 14px;
			}

			.lli {
				margin-right: 30px;
				color: #666;
			}
		}
	}
</style>
